﻿using System;
using System.Collections.Generic;
using System.Text;
using Wangzeran.CodeMaker.Core.Tag;

namespace Wangzeran.CodeMaker.PlugIns.Tags
{
    /// <summary>
    /// 文件名标签
    /// </summary>
    public class FileNameTag : TagSupport
    {
        /// <summary>
        /// 文件名称
        /// </summary>
        private const string ATTR_NAME = "name";
        /// <summary>
        /// 标签名称
        /// </summary>
        public override string TagName
        {
            get { return "c:filename"; }
        }

        /// <summary>
        /// 处理标签
        /// </summary>
        /// <param name="tagStr">标签文本</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        public override string ProcessTag(string tagStr, object value)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                if (this.Properties.ContainsKey(ATTR_NAME))
                {
                    ITag tag = new ValueTag();
                    string result = tag.Process(this.Properties[ATTR_NAME], value);
                    sb.AppendLine(result);
                }

                return sb.ToString();
            }
            catch (Exception ex)
            {	
                throw ex;
            }
        }
    }
}
